<?php

namespace Console\Controller;

/**
 * 在线客服
 * Class OnlineController
 * @package Console\Controller
 */
class OnlineController extends CstBaseController
{

    private $onlineLogic;

    public function _initialize()
    {
        parent::_initialize();
        $this->onlineLogic = A('Console/Online', 'Logic');
    }

    /**
     * 编辑分成配置
     */
    public function edit()
    {
        $infoRes = $this->onlineLogic->getInfo();
        $info = $infoRes['Result'];
        $this->assign("info", $info);
        $this->display();
    }

    /**
     * 提交编辑分成配置
     */
    public function doEdit()
    {
        $data = I('post.');
        $id = $data['id'];
        unset($data['id']);

        if (empty($id)) {
            $this->ajaxReturn(static::$res->err("系统异常"));
        }

        $userInfo = $this->getUserInfo();
        $userId = $userInfo['id'];

        $res = $this->onlineLogic->edit($id, $userId, $data);
        $this->ajaxReturn($res);
    }


}
